Java Native Interface idioms for C++ class hierarchies

نویسندگان

  • Dale Parson
  • Zhenyu Zhu
چکیده

SUMMARY The Java™ Native Interface (JNI) provides a set of mechanisms for implementing Java methods in C or C++. JNI is useful for reusing C and C++ code repositories within Java frameworks. JNI is also useful for real-time systems, where compiled C/C++ code executes performance-critical tasks, while Java code executes system control and feature tasks. Available JNI literature concentrates on creating Java proxy classes that allow Java clients to interact with C++ classes. Current JNI literature does not discuss Java proxies for entire C++ inheritance hierarchies; that is the topic of this paper. Our experience in reusing C++ class hierarchies within a Java framework has uncovered a set of useful techniques for constructing Java proxy class hierarchies that mirror their C++ counterparts. This report gives both high level design guidelines and specific programming idioms for constructing Java class hierarchies that serve as proxies for C++ counterparts. We begin by discussing opportunities for reuse within a proxy class hierarchy, as well as problems caused by differences between the Java and C++ approaches to inheritance. The two most significant differences are due to C++ support for invocation of a member function based on the static type of its class, and C++ support for multiple implementation inheritance. Two example C++ class hierarchies provide the basis for a set of sections that present the design guidelines and that codify the programming idioms. This work could serve as the basis for an automatic generator of Java proxy class hierarchies. The Java Native Interface [1] is a set of software mechanisms that support interaction between Java modules on one side of JNI and C/C++ modules on the other. A Java method declaration marked with the keyword native is identified as a native method written in C or C++. Within a Java source file a native method appears strictly as a method signature declaration; it contains no Java code. Invoking the generator program javah with a compiled Java class as an argument creates a C/C++ function declaration equivalent to each native method declaration. Each generated declaration serves as the starting point from which a programmer can write a C or C++ implementation of its method. Native methods can construct, delete and interact with C data structures and C++ objects. A Java system can dynamically load native methods. Conversely, a C or C++ system can construct a Java Virtual Machine (JVM) and interact with it via JNI. Many …

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Easing the Transition from C++ to Java (Part 2)

In Part I of this article [1], we discussed how to address the problem of making Java and C++ co-exist in the same baseline. We introduced the Java Native Interface Simplified (JNIS) Framework as a simple mechanism that relies on common design idioms such as the Command and Observer patterns [2]. Instead of depending directly upon the JNI interface, we hide the details of JNI behind a set of C+...

متن کامل

Eliminating Cycles in Composed Class Hierarchies

Multiple class hierarchies can be used each to represent a separate requirement or design concern. To yield a working system, these disparate hierarchies must be composed in a semantically meaningful way. However, cycles can arise in the composed inheritance graph that restrict the space of composable hierarchies. This work presents an approach to eliminating these cycles by means of separating...

متن کامل

Java2OWL: A System for Synchronising Java and OWL

Java2OWL is a Java software library for synchronising Java class hierarchies with OWL concept hierarchies. With a few extra annotations in Java class files, the Java2OWL library can automatically map Java class hierarchies to OWL ontologies. The instances of these Java classes are automatically mapped to OWL individuals and vice versa. OWL reasoners can be used as query processors to retrieve i...

متن کامل

A Reasonable C++ Wrappered Java Native Interface

A reasonable C++ Java Native Interface (JNI) technique termed C++ Wrappered JNI (C++WJ) is presented. The technique simplifies current error-prone JNI development by wrappering JNI calls. Provided development is done with the aid of a C++ compiler, C++WJ offers type checking and behind the scenes caching. A tool (jH) patterned on javah automates the creation of C++WJ classes. The paper presents...

متن کامل

Generating Java Class Skeleton Using a Natural Language Interface

An intelligent natural language interface based on Turkish Language is designed for creating Java class skeleton, listing the class and its members. This interface is developed as a part of a project named as TUJA, a tool for producing Java programs using Turkish sentences. Turkish sentences are converted into instances of schemata, representing classes and their members. Concept hierarchies ar...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Softw., Pract. Exper.

دوره 30  شماره 

صفحات  -

تاریخ انتشار 2000